@extends('home.layout.base')
@section('content')
		<form  method="post"  id="resform" class="layui-form">
			{{ csrf_field() }}
		<div class="regist">
			<div class="regist_center">
				<div class="regist_top">
					<div class="left fl">会员注册</div>
					<div class="right fr"><a href="./index.html" target="_self">小米商城</a></div>
					<div class="clear"></div>
					<div class="xian center"></div>
				</div>
				<div class="regist_main center">
					<div class="username">邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;箱:&nbsp;&nbsp;<input class="shurukuang" type="text" name="email" lay-verify="required|email" placeholder="请输入你的邮箱"/><span></span></div>
					<div class="username">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名:&nbsp;&nbsp;<input class="shurukuang" type="text" name="name" lay-verify="required" placeholder="请输入你的姓名"/><span></span></div>
					<div class="username">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;&nbsp;<input class="shurukuang" type="password" name="password" lay-verify="required" placeholder="请输入你的密码"/><span>请输入6位以上字符</span></div>
					
					<div class="username">确认密码:&nbsp;&nbsp;<input class="shurukuang" type="password" name="password_confirmation"  lay-verify="required" placeholder="请确认你的密码"/><span>两次密码要输入一致哦</span></div>
					<div class="username">手&nbsp;&nbsp;机&nbsp;&nbsp;号:&nbsp;&nbsp;<input class="shurukuang" type="text" name="phone" lay-verify="phone" placeholder="请填写正确的手机号"/><span>填写下手机号吧，方便我们联系您！</span></div>
					<div class="username">
						<div class="left fl">验&nbsp;&nbsp;证&nbsp;&nbsp;码:&nbsp;&nbsp;<input class="yanzhengma" type="text" name="captcha" lay-verify="required" placeholder="请输入验证码"/></div>
						<div class="right fl"><a href="javascript:;"><img src="{{captcha_src()}}" id="captcha"></a></div>
						<div class="clear"></div>
					</div>
				</div>
				<div class="regist_submit">
					<input class="submit" type="submit" name="submit" lay-submit="" lay-filter="resform" value="立即注册" >
				</div>
				
			</div>
		</div>
		</form>
	</body>
</html>
@endsection
@section('js')
<script type="text/javascript">
    layui.use(['form','layer', 'jquery'],function () {
		var layer= layui.layer, form = layui.form, $ = layui.jquery;
        form.on('submit(resform)', function(data){
            var userinfo = data.field; //当前容器的全部表单字段，名值对形式：{name: value}
			$.post('/register',userinfo,function (res) {
				if(res.code == 0){
                    layer.msg(res.data, function(){
                        window.location.href="/login";
                    });
                }else {
                    layer.msg(res.data);
				}
			    return false;
            },'json');
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        $('#captcha').click(function () {
			$(this).attr('src', '/captcha/?' + Math.random());
        });
    });
</script>
@endsection